<html>
<head>
<meta charset="utf-8">
<title>订单展示</title>

<link rel="stylesheet" href="css/bootstrap.min.css">
<script src="js/jquery/jquery.min.js"></script>
<script src="js/jquery.validation/1.14.0/jquery.validate.min.js"></script>
<script src="js/jquery.validation/1.14.0/messages_zh.min.js"></script>
<style>
	input.error {
		border: 1px solid #E6594E;
	}
</style>
</head>



<body>
	<div class="container">
		<form role="addOrder">
			<div class="form-group">
				<label for="order">订单名称</label> 
				<input type="text" class="form-control" id="order" name="order" placeholder="订单名称">
			</div>
			<div class="form-group">
				<label for="price">价格</label> 
				<input type="text" class="form-control" id="price" name="price" placeholder="价格">
			</div>
			<div class="form-group">
				<label for="photo">图片</label> 
				<input type="file" id="photo">
			</div>
			<button type="button" id="saveOrder" class="btn btn-default">提交</button>
			<button type="button" id="cancleOrder" class="btn btn-default">取消</button>
		</form>
	</div>
	<script>
		var addOrder = function(){
			
			$.ajax({
				type:"GET",
				dataType:"json",
				url:"/order/add",
				data:{
					"name":$('#order').val(),
					"price":$('#price').val(),
				},
				success:function(){
					$('#cancleOrder').click();
				}
			});
		}
		//提交
		$('#saveOrder').on('click',function(){
			addOrder();
		})
		
		//取消
		$('#cancleOrder').on('click',function(){
			var index = parent.layer.getFrameIndex(window.name);
			parent.getUserPageList();
			parent.layer.close(index);
		})
		
		function check(){
			return $("#addOrder").validate({
	    		 rules: {
	    			order: {
	       				 required: true
	      			},
	      			price: {
	       				 required: true
	      			}
	    		 },	
	    		messages: {
	      			order: {
	       				 required: "请输入订单名称"	       				
	      			},
	      			price: {
	        			required: "请输入输入价格"
	     			}
	    		},
			});
		}
		
	</script>

</body>
</html>
